package com.feather.common.db;

import java.sql.Types;

/**
 * @author flogyin
 */
public class SqlTypesUtil {
	private static final String[]	TYPES	= { "BIT", "TINYINT", "SMALLINT", "INTEGER", "BIGINT", "FLOAT", "REAL", "DOUBLE", "NUMERIC", "DECIMAL", "CHAR", "VARCHAR", "LONGVARCHAR", "DATE", "TIME", "TIMESTAMP", "BINARY", "VARBINARY", "LONGVARBINARY", "NULL", "OTHER", "JAVA_OBJECT", "DISTINCT", "STRUCT", "ARRAY", "BLOB", "CLOB", "REF", "DATALINK", "BOOLEAN" };

	private SqlTypesUtil() {
	}

	public static String[] types() {
		String[] ret = new String[TYPES.length];
		System.arraycopy(TYPES, 0, ret, 0, ret.length);
		return ret;
	}

	public static String name(int type) {
		switch (type) {
			case Types.BIT:
				return TYPES[0];
			case Types.TINYINT:
				return TYPES[1];
			case Types.SMALLINT:
				return TYPES[2];
			case Types.INTEGER:
				return TYPES[3];

			case Types.BIGINT:
				return TYPES[4];
			case Types.FLOAT:
				return TYPES[5];
			case Types.REAL:
				return TYPES[6];
			case Types.DOUBLE:
				return TYPES[7];

			case Types.NUMERIC:
				return TYPES[8];
			case Types.DECIMAL:
				return TYPES[9];
			case Types.CHAR:
				return TYPES[10];
			case Types.VARCHAR:
				return TYPES[11];

			case Types.LONGVARCHAR:
				return TYPES[12];
			case Types.DATE:
				return TYPES[13];
			case Types.TIME:
				return TYPES[14];
			case Types.TIMESTAMP:
				return TYPES[15];

			case Types.BINARY:
				return TYPES[16];
			case Types.VARBINARY:
				return TYPES[17];
			case Types.LONGVARBINARY:
				return TYPES[18];
			case Types.NULL:
				return TYPES[19];

			case Types.OTHER:
				return TYPES[20];
			case Types.JAVA_OBJECT:
				return TYPES[21];
			case Types.DISTINCT:
				return TYPES[22];
			case Types.STRUCT:
				return TYPES[23];

			case Types.ARRAY:
				return TYPES[24];
			case Types.BLOB:
				return TYPES[25];
			case Types.CLOB:
				return TYPES[26];
			case Types.REF:
				return TYPES[27];

			case Types.DATALINK:
				return TYPES[28];
			case Types.BOOLEAN:
				return TYPES[29];
		}
		return null;
	}

	// public static int type(String name) {return null}
}
